/********************************************************************



Write Date: 2011/03/28
Author: Deng Nianchen
>>>> 
	
*********************************************************************/
#ifndef SOCK_CONNECTION_H
#define SOCK_CONNECTION_H
#include <ooputils/Ptr.hpp>
#include <ooputils/ByteStream.h>
#include "Global.hpp"


_OOPNETWORK_BEGIN

class SocketListener;


class _EXPORT_NETWORK_CLASS SockConnection : public OOPUtils::OOPObject
{
  
  friend class SocketListener;

private:

  SocketListener & _listener;
  SOCKET _socket;
  sockaddr_in _clientAddr;
  char * _buffer;
  size_t _bufferSize;

  SockConnection (SocketListener & listener, SOCKET socket,
    sockaddr_in clientAddr);

public:

  virtual ~SockConnection ();

  void sendData (const OOPUtils::ByteStream & data) const;

  OOPUtils::PtrBase< OOPUtils::ByteStream > receiveData () const;

  void closeConnection () const;

  std::string getClientIP () const;

  unsigned int getClientPort () const;

};

_OOPNETWORK_END

#endif